<?php 
namespace app\models;
use Yii;
use yii\db\ActiveRecord;
use app\models\User;
use app\models\Article;
use app\models\Live;
use app\models\Xiong;
class Comment_live extends ActiveRecord
{
    public static function tableName()
    {
        return 'comment_live';
    }
     public function rules()
    {
            return [
                 [['comment_name', 'comment_content'], 'required',],
                    
                ]
                 ;
     }
    
    
     public function attributeLabels()
    {
        return [
            'comment_name' => 'username',
            'comment_content' => '评论内容',
            
        ];
    }
    public  function getUserName($user_id)
    {
        $user = User::find()->where(['id'=>$user_id])->one();
        if($user==null)
            return "游客";
        else
        return $user->username;
    }
    public static function getLiveNameById($live_id)
    {
        if($live_id==null)
            return "";
        $live = Live::find()->where(['id'=>$live_id])->one();
        return $live->live_title;
    }
    public  function getLivePostName($live_id)
    {
        $live = Live::find()->where(['id'=>$live_id])->one();
        return $live->post_name;
    }
    // 管理系统获取的comment数据
   
    public static function getCommByLiveId($live_id)
    {
        $comment= static::find()->where(['live_id'=>$live_id])->orderBy('comment_id desc')->all();
       
        
         return $comment;
    }
}

 ?>